package com.open.party.cloud

import androidx.fragment.app.Fragment
import androidx.viewpager.widget.ViewPager
import com.gyf.immersionbar.ImmersionBar
import com.open.party.cloud.view.*
import com.open.party.cloud.view.comm.MainBaseActivity
import com.sinothk.tab.weiXin.WxTabMenuMainAdapter
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : MainBaseActivity() {

    override fun initTab() {
        val fragments = ArrayList<Fragment>()

        fragments.add(HomeMainFragment0101())
//        fragments.add(OrgMainFragment())
        fragments.add(DangJianMainFragment())
        fragments.add(XueXiMainFragment())
        fragments.add(GanBuMainFragment())
        fragments.add(RenCaiMainFragment())//MineMainFragment()

        val mainAdapter = WxTabMenuMainAdapter(supportFragmentManager, alphaIndicator, fragments)
        mViewPager!!.adapter = mainAdapter
        mViewPager!!.offscreenPageLimit = fragments.size - 1

        // 监听滑动，动态显示TitleBar内容
        mViewPager!!.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
            override fun onPageScrollStateChanged(state: Int) {
            }

            override fun onPageScrolled(
                position: Int,
                positionOffset: Float,
                positionOffsetPixels: Int
            ) {
            }

            override fun onPageSelected(position: Int) {
//                if (position == 0 || position == 3) {
//                    ImmersionBar.with(this@MainActivity)
//                        .statusBarDarkFont(false).init()
//
////                    if (position == 3) {
////                        // 需要登录项
////                        if (!LocalCache.getAutoLogin()) {
////                            // 登录检测
////                            XUtils.intent().openActivity(this@MainActivity, LoginActivity::class.java)
////                                .start()
////                            return
////                        }
////                    }
//                } else {
//                    ImmersionBar.with(this@MainActivity)
//                        .statusBarDarkFont(true).init()
//                }
            }
        })

        alphaIndicator.setViewPager(mViewPager)
    }
}
